﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		termId = event.getArg("TermIDRST");
		termstart = event.getArg("DateStartRST");
		
		/* 学籍相关信息 */
		studentId = sessionAdvice.getAutherUserID();
		
		if ( len(studentId) and len(termId) ) {
			
			sql = "SELECT 
					t_course.course_name, 
					t_resittask.wid, t_resittask.wdidx, 
					t_examcell.cellidx, t_examcell.time_start, t_examcell.time_end, 
					sitidx, 
					t_classroom.classroom, t_classroom.cr_floor, 
					t_campus.campus_name, 
					t_building.b_name 
					FROM t_student_resit 
					INNER JOIN t_resittask ON t_resittask.task_exrstid = t_student_resit.task_exrstid 
					INNER JOIN t_course ON t_course.cid = t_resittask.cid 
					INNER JOIN t_examcell ON t_examcell.cellidx = t_resittask.cellidx 
					INNER JOIN t_classroom ON t_classroom.cr_id = t_student_resit.cr_id
					INNER JOIN t_campus ON t_campus.campus_id = t_classroom.campus_id 
					INNER JOIN t_building ON t_building.b_id = t_classroom.b_id 
					WHERE 
						t_resittask.task_prog = '3' 
						AND 
						t_resittask.term_id = :termId 
						AND 
						stu_id = :studentId 
					ORDER BY 
						t_resittask.wid, t_resittask.wdidx, t_examcell.cellidx ";
		
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="studentId", value=studentId, cfsqltype="cf_sql_varchar" );

			rs_exam = queryObj.execute( sql=sql ).getResult();
			
		}

	</cfscript>
</cfsilent>

<cfif rs_exam.recordCount>
	<table class="UIEditable">
		<thead>
			<tr>
				<td width="18"></td>
				<td>课程</td>
				<td width="30">周次</td>
				<td width="70">场次</td>
				<td width="70">日期</td>
				<td width="80">时间</td>
				<td>考场</td>
				<td width="30">座次</td>
				<td>考场所在地点</td>
			</tr>
		</thead>
		<tbody>
			<cfset row = 0 />
			<cfloop query="rs_exam">
				<cfset row++ />
				<tr class="editRows">
					<td class="index"><cfoutput>#row#</cfoutput></td>
					<td><cfoutput>#rs_exam.course_name#</cfoutput></td>
					<td><span class="numeric"><cfoutput>#rs_exam.wid#</cfoutput></span></td>
					<td><cfoutput>#mathAdvice.convertWeekDayToChinese( rs_exam.wdidx )#</cfoutput><cfoutput>#mathAdvice.convertExamIdxToChinese( rs_exam.cellidx )#</cfoutput></td>
					<td><span class="numeric"><cfoutput>#datetimeAdvice.formatDateString( mathAdvice.revertTaskWeekDay( termstart, rs_exam.wid, rs_exam.wdidx ), "YYYY/MM/DD")#</cfoutput></span></td>
					<td><span class="numeric"><cfoutput>#datetimeAdvice.formatTimeString(rs_exam.time_start, "HH:MI")#</cfoutput>-<cfoutput>#datetimeAdvice.formatTimeString(rs_exam.time_end, "HH:MI")#</cfoutput></span></td>
					<td><cfoutput>#rs_exam.classroom#</cfoutput></td>
					<td><span class="numeric"><cfoutput>#rs_exam.sitidx#</cfoutput></span></td>
					<td><cfoutput>#rs_exam.campus_name#</cfoutput><cfoutput>#rs_exam.b_name#</cfoutput><cfoutput>#dictAdvice.getFloorString(rs_exam.cr_floor)#</cfoutput></td>
				</tr>
			</cfloop>
		</tbody>	
	</table>
	<cfelse>
	<div class="systemNotice">
		<h3>目前期中考试安排还未发布</h3>
	</div>
</cfif>